class Solution(object):
    def maskPII(self, s):
        """
        :type s: str
        :rtype: str
        """
        if '@' in s:
            s = s.split('@')
            s[0] = s[0].lower()
            s[1] = s[1].lower()
            return s[0][0] + '*' * 5 + s[0][-1] + '@' + s[1]
        else:
            t = ''
            for c in s:
                if '0' <= c <= '9':
                    t += c
            if len(t) == 10:
                return '***-***-' + t[-4:]
            if len(t) == 11:
                return '+*-***-***-' + t[-4:]
            if len(t) == 12:
                return '+**-***-***-' + t[-4:]
            if len(t) == 13:
                return '+***-***-***-' + t[-4:]


data = Solution()
s = "LeetCode@LeetCode.com"
print(data.maskPII(s))
